<?php
    /* @var   $this UserController */
    /* @user  $model Users */
    /* @model $this Profiles */
    $cs = Yii::app()->getClientScript(); 
    // Css
    $cs->registerCssFile(Html::url('uploadify/uploadify.css'), 'screen');
    
    // Js
    $cs->registerScriptFile(Html::url('uploadify/jquery.uploadify-3.1.min.js'));
?>

<script>
    $(document).ready(function(){
        $(function() {
            $('#file_upload').uploadify({
                'swf'      : '<?php echo Html::url('uploadify/uploadify.swf') ?>',
                'uploader' : '<?php echo Html::url('uploadify/uploadify.php') ?>',
                'method'   : 'post',
                'formData' : {'path': '<?php echo Yii::getPathOfAlias('webroot').'/avatars'?>'},
                'onUploadSuccess' : function(file, data, response) {
                    $("#avatar_preview").attr("src",'<?php echo Html::avatarUrl('')?>' + data);
                    $("#TUsers_avatar").val(data);
                }
            });
        });
    })
</script>

<div class="content-main">
    <div class="content-header">
        <div class="header-inner">
            <h2>Profile</h2>
            <p class="subheader">This information appears on your public profile, search results, and beyond.</p>
        </div>
    </div>
    <div class="content-inner no-stream-end">
        <?php
            $form = $this->beginWidget('CActiveForm',array(
                'id'=>'profile-form',
                'htmlOptions'=>array(
                    'class'=>"form-horizontal",
                    'id'=>"profile-form",
                ),
            ));
        ?>
            <div style="display: none;" class="alert" id="settings-alert-box">
                <i class="close" id="settings-alert-close"></i>
            </div>
            <fieldset class="control-group" id="profile-image-controls">
                <label for="profile_image_uploaded_data" class="control-label">Picture</label>
                <div class="controls">
                    <div class="uploader-avatar clearfix">
                        <img src="<?php echo Html::avatarUrl($model->avatar)?>" id="avatar_preview" class="avatar size73">
                        <div class="uploader-tools">
                            <div class="photo-selector">
                                <?php echo $form->hiddenField($model, 'avatar') ?>
                                <input type="file" name="file_upload" id="file_upload"/>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>              <hr>
            <fieldset class="control-group">
                <label for="user_name" class="control-label">Name</label>
                <div class="controls">
                    <?php echo $form->textField($model, 'full_name')?>
                    <p>Enter your real name, so people you know can recognize you.</p>
                </div>
            </fieldset>
            <fieldset class="control-group">
                <label for="user_location" class="control-label">Location</label>
                <div class="controls">
                    <?php echo $form->textField($model, 'location')?>
                    <p>Where in the world are you?</p>
                </div>
            </fieldset>
            <fieldset class="control-group" id="user_web_fieldset">
                <label for="user_url" class="control-label">Website</label>
                <div class="controls">
                    <?php echo $form->textField($model, 'website')?>
                    <p>Have a homepage or a blog? Put the address here.</p>
                </div>
                <div class="controls">
                </div>
            </fieldset>
            <fieldset class="control-group">
                <label for="user_description" class="control-label">Bio</label>
                <div class="controls">
                    <?php echo $form->textArea($model, 'bio',array('maxlength'=>"160", 'class'=>"input-xlarge"))?>
                    
                    <p>About yourself in fewer than <strong>160</strong> characters.</p>
                </div>
            </fieldset>

            <hr>
            <div class="form-actions">
                <button type="submit" class="btn primary-btn" id="settings_save">Save changes</button>
            </div>            
        <?php $this->endWidget()?>
    </div>
</div>